package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public interface SetmealMapper {
    /**
     * 修改套餐
     *
 * @param setmeal
     * @return
     * @author heiheiheng
     * @create 2025/7/25
     **/
    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    /**
     * 套餐分页查询
     *
 * @param setmealPageQueryDTO
     * @return
     * @author heiheiheng
     * @create 2025/7/26
     **/
    Page<SetmealVO> pageSetmealQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 根据id查询套餐
     *
 * @param id
     * @return
     * @author heiheiheng
     * @create 2025/8/2
     **/
    @Select("select * from setmeal where id=#{id}")
    Setmeal getSetmealById(Long id);

    /**
     * 根据套餐id删除绑定在套餐上的菜品
     * @param id
     */
    @Delete("delete from setmeal_dish where id=#{id}")
    void deleteSetmealDish(Long id);


    /**
     * 根据套餐id批量删除套餐
     * @param ids
     */
    void batchDeleteSetmeal(ArrayList<Long> ids);

    /**
     * 批量插入绑定菜品
     *
 * @param setmealDishes
     * @return
     * @author heiheiheng
     * @create 2025/8/2
     **/
    void insertBathSetmealDish(List<SetmealDish> setmealDishes);

    /**
     * 插入套餐信息
     *
 * @param setmeal
     * @return
     * @author heiheiheng
     * @create 2025/8/2
     **/
    @AutoFill(OperationType.INSERT)
    void insertSetmeal(Setmeal setmeal);

    /**
     * 根据id查询套餐关联的菜品
     *
 * @param id
     * @return
     * @author heiheiheng
     * @create 2025/8/2
     **/
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getSetmealDishById(Long id);

    /**
     * 动态条件查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> list(Setmeal setmeal);

    /**
     * 查询套餐
     *
 * @param map
     * @return
     * @author heiheiheng
     * @create 2025/8/13
     **/
    Integer countByMap(Map map);
}
